package tech.aistar.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tech.aistar.mapper.SongListMapper;
import tech.aistar.pojo.PictureTable;
import tech.aistar.pojo.SongList;
import tech.aistar.pojo.entity.SingerList;

import java.util.List;
@Service
@Transactional
public class SongListServiceImpl implements SongListService{
    @Autowired
    private SongListMapper songListMapper;
    @Override
    public List<SongList> findAll(String songTitle) {
        songTitle=songTitle==null?"":songTitle;
        return songListMapper.findAll(songTitle);
    }

    @Override
    public List<SongList> findAlllist(Integer id) {
        return songListMapper.findAlllist(id);
    }
    @Override
    public List<SongList> findAlllist1(Integer id) {
        return songListMapper.findAlllist1(id);
    }


    @Override
    public PageInfo<SongList> findBypicture(Integer id, Integer pageNum, Integer pageSize) {
        Page<SongList> page = PageHelper.startPage(pageNum,pageSize);
        //定义一个PageInfo
        PageInfo<SongList> pageInfo = null;

        List<SongList> topics = null;
        topics = songListMapper.findAlllist(id);
        pageInfo = new PageInfo<>(topics);
        return pageInfo;
    }
    @Override
    public PageInfo<SongList> findBypictures(Integer id, Integer pageNum, Integer pageSize) {
        Page<SongList> page1 = PageHelper.startPage(pageNum,pageSize);
        //定义一个PageInfo
        PageInfo<SongList> pageInfo1 = null;

        List<SongList> topics1 = null;
        topics1= songListMapper.findAlllist1(id);
        pageInfo1 = new PageInfo<>(topics1);
        return pageInfo1;
    }

    @Override
    public List<SongList> getBySingerName(String singerName) {
        return songListMapper.getBySingerName(singerName);
    }


    @Override
    public List<SongList> getSongId(Integer id) {
        return songListMapper.getBySongId(id);
    }

    @Override

    public List<SongList> Allfind() {
        return songListMapper.Allfind();
//    public List<SongList> getBySId(Integer songListId) {
//        return songListMapper.getBySId(songListId);
    }

    @Override

    public List<SongList> selectAll(String songTitle, String singerName, String lyrics) {
        return songListMapper.selectAll(songTitle, singerName, lyrics);
    }

    @Override
    public PageInfo<SongList> finds(String searchkey, Integer pageNum, Integer PageSize) {
        Page<Object> page=PageHelper.startPage(pageNum,PageSize);
        List<SongList> songLists=songListMapper.findAllsearch(searchkey);
        PageHelper.startPage(pageNum,PageSize);
        PageInfo<SongList> pageInfo=new PageInfo<>(songLists);
        return pageInfo;
    }

    @Override
    public List<SongList> getBySongId(Integer id) {
        return songListMapper.getBySongId(id);

    }

    @Override
    public SongList getSongBySongTitle(String songTitle) {
        return songListMapper.getSongBySongTitle(songTitle);
    }

    @Override
    public SongList getBySongI(Integer id) {
        return songListMapper.getBySongI(id);
    }

    @Override
    public List<SongList> hotSong() {
        return  songListMapper.hotSong();
    }

//    @Override
//    public List<SongList> getBySId(Integer songListId) {
//        return  songListMapper.getBySId(songListId);
//    }
    }

